package thread.synchroCode;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

// 使用park和unpark 先打印B，再打印A
@Slf4j(topic = "c.Test2")
public class _08ParkUnPark {
  public static void main(String[] args) {

    Thread t1 = new Thread(() -> {
      LockSupport.park();
      log.debug("b");
    });


    Thread t2 = new Thread(() -> {
      log.debug("a");
      LockSupport.unpark(t1);
    });

    t1.start();
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    t2.start();
  }
}
